package com.xnx.bincker.leader.service.impl;

import com.xnx.bincker.leader.domain.Role;
import com.xnx.bincker.leader.service.RoleService;
import org.springframework.data.domain.Example;
import org.springframework.stereotype.Service;

import java.util.Optional;

@Service
public class RoleServiceImpl extends BasicServiceImpl<Role, String> implements RoleService {
	/**
	 * 通过角色Code查找角色
	 * @param code 角色Code
	 */
	public Optional<Role> findByCode(String code){
		Role role = new Role();
		role.setCode("ROLE_" + code.toUpperCase());
		return repository.findOne(Example.of(role));
	}

}
